const express = require('express')
const { ApolloServer, gql } = require('apollo-server-express')

const typeDefs = gql`
  #枚举类型
  enum Favour {
    SWIMMING
    DANCEING
    CODING
  }
  #查询类型
  type Query {
    hello: String
    info: Favour
  }
`

const resolvers = {
  Query: {
    hello: () => 'Hello world!111',
    info: () => {
      return 'DANCEING'
    }
  }
}

const server = new ApolloServer({ typeDefs, resolvers })

const app = express()
server.applyMiddleware({ app })

app.listen({ port: 4000 }, () => console.log('Now browse to http://localhost:4000' + server.graphqlPath))
